const checkMail = (rule, value, cb) => {
    const regEmail =
        /^([a-zA-Z0-9])+(([a-zA-Z0-9])|([._-][a-zA-Z0-9])*)+@([a-zA-Z0-9-])+((\.[a-zA-Z0-9-]{2,3}){1,2})$/;
    if (regEmail.test(value)) {
        return cb();
    }
    cb(new Error("请输入合法邮箱"));
};
const checkMobile = (rule, value, cb) => {
    const regMobile = /^[1][3,4,5,7,8,9][0-9]{9}$/;
    if (regMobile.test(value)) {
        return cb();
    }
    cb(new Error("请输入合法手机号"));
};

const username = [
    { required: true, message: "请输入用户名", trigger: "blur" },
    { min: 1, max: 10, message: "长度在 1 到 10 个字符", trigger: "blur" },
]
const password = [
    { required: true, message: "请输入密码", trigger: "blur" },
    { min: 3, max: 15, message: "长度在 3 到 15 个字符", trigger: "blur" },
]
const email = [
    { required: false, message: "请输入邮箱", trigger: "blur" },
    { min: 1, max: 15, message: "长度在 1 到 15 个字符", trigger: "blur" },
    { validator: checkMail, trigger: "blur" },
]
const mobile = [
    { required: false, message: "请输入手机号", trigger: "blur" },
    { min: 1, max: 11, message: "1至11位数字", trigger: "blur" },
    { validator: checkMobile, trigger: "blur" },
]
const tagName = [
    { required: true, message: "请输入标签名", trigger: "blur" },
    { min: 1, max: 10, message: "长度在 1 到 10 个字符", trigger: "blur" },
]
const userFormRules = { username, password, email, mobile };
const loginFormRules = { username, password }
const tagFormRules = { tagName }
export {
    userFormRules,
    loginFormRules,
    tagFormRules
}